//
//  ContactsCell.m
//  e律师
//
//  Created by 韦淋 on 2017/6/2.
//  Copyright © 2017年 test. All rights reserved.
//

#import "ContactsCell.h"


#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height


@interface ContactsCell ()


@end

@implementation ContactsCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //布局View
        [self setUpView];
    }
    return self;
}

#pragma mark - setUpView
- (void)setUpView{
    
    //头像
    [self.contentView addSubview:self.infoLable];
    //姓名
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.callButton];
    [self.contentView addSubview:self.textbutton];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.callButton.frame = CGRectMake(270, 5, 40, 40);
    self.textbutton.frame = CGRectMake(320, 5, 40, 40);
    self.infoLable.frame = CGRectMake(150.0, 5.0, 100, 40.0);
    self.nameLabel.frame = CGRectMake(50.0, 5.0, 100.0, 40.0);
    
}
- (UIButton *)callButton{
    if (!_callButton) {
        _callButton = [[UIButton alloc] init];
        _callButton.backgroundColor = [UIColor colorWithRed:102.0f/255.0f green:159.0f/255.0f blue:190.0f/255.0f alpha:1.0f];
        [_callButton addTarget:self action:@selector(didClickCallButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _callButton;
}
- (UIButton *)textbutton{
    if (!_textbutton) {
        _textbutton = [[UIButton alloc] init];
        _textbutton.backgroundColor = [UIColor colorWithRed:102.0f/255.0f green:159.0f/255.0f blue:190.0f/255.0f alpha:1.0f];
        [_textbutton addTarget:self action:@selector(didClickTextButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _textbutton;
}
- (UILabel *)infoLable{
    if (!_infoLable) {
        _infoLable=[[UILabel alloc] init];
        [_infoLable setContentMode:UIViewContentModeScaleAspectFill];
        _infoLable.numberOfLines = 2;
        [_infoLable setFont:[UIFont systemFontOfSize:14.0]];
    }
    return _infoLable;
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel=[[UILabel alloc] init];
        [_nameLabel setFont:[UIFont systemFontOfSize:15.0]];
    }
    return _nameLabel;
}
//按钮方法
-(void)didClickCallButton:(UIButton*)sender
{
    
    
    if ([self.delegate respondsToSelector:@selector(didClickCallButtonAction:)]) {
        [self.delegate didClickCallButtonAction:sender];
    }
}
-(void)didClickTextButton:(UIButton*)sender
{
    
    if ([self.delegate respondsToSelector:@selector(didClickTextButtonAction:)]) {
        [self.delegate didClickTextButtonAction:sender];
    }
}
@end
